﻿namespace LanSunERP
{
    using System;
    using System.ServiceModel;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.Collections;
    using System.Data;
    using System.Data.SqlClient;

    public class SalesOrder:QueryCommand
    {
              public SalesOrder() : base () { }
              public SalesOrder(SqlCommand cmdSQL, DataTable dtRequest,string RequestJob)
         : base(cmdSQL, dtRequest,RequestJob) {  }

        public SqlCommand BuildCommand()
        {
           switch (RequestJob.Substring(6, 10))
            {

                #region SalesOrder
                case "0000": break;
                case "1000": break;
                case "1001":
                    cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@InstanceID", dwRequest["InstanceID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@CustomerInstanceID", dwRequest["CustomerInstanceID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@CustomerFullName", dwRequest["CustomerFullName"].ToString()));
                    break;
                case "1002": break;
                case "2000": 
                case "3000":
                    cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@InstanceID", dwRequest["InstanceID"].ToString()));
                    cmdSQL = BuildInstanceKey(cmdSQL, dwRequest);
                    cmdSQL.Parameters.Add(new SqlParameter("@UpperInstanceID", dwRequest["UpperInstanceID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@UpperInstanceKey", dwRequest["UpperInstanceKey"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@CustomerInstanceID", dwRequest["CustomerInstanceID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@CustomerFullName", dwRequest["CustomerFullName"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Type", dwRequest["Type"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Contact", dwRequest["Contact"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@PaymentTerm", dwRequest["PaymentTerm"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Currency", dwRequest["Currency"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@PriceGroup", dwRequest["PriceGroup"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@OrderWay", dwRequest["OrderWay"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@ShipmentKind", dwRequest["ShipmentKind"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@DeliveryTerms", dwRequest["DeliveryTerms"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@DeliveryAddress", dwRequest["DeliveryAddress"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@GoodsInstanceID", dwRequest["GoodsInstanceID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Quantity", dwRequest["Quantity"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@OverShort", dwRequest["OverShort"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@MeasureUnit", dwRequest["MeasureUnit"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@RequestDate", dwRequest["RequestDate"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@DeliveryDate", dwRequest["DeliveryDate"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@FollowUpdate", dwRequest["FollowUpdate"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@SubStatus", dwRequest["SubStatus"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Status", dwRequest["Status"].ToString()));
                    
                    break;
                case "2001":case "4000":
                    cmdSQL.Parameters.Add(new SqlParameter("@InstanceID", dwRequest["InstanceID"].ToString())); 
                    break;
                #endregion
            }
             return cmdSQL;

        }      

    }
}